/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jp.co.irep.juten.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author toan_nguyen
 */
@Entity
@Table(name = "login_user")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LoginUser.findAll", query = "SELECT l FROM LoginUser l"),
    @NamedQuery(name = "LoginUser.findById", query = "SELECT l FROM LoginUser l WHERE l.id = :id"),
    @NamedQuery(name = "LoginUser.findByUname", query = "SELECT l FROM LoginUser l WHERE l.uname = :uname"),
    @NamedQuery(name = "LoginUser.findByUpass", query = "SELECT l FROM LoginUser l WHERE l.upass = :upass"),
    @NamedQuery(name = "LoginUser.findByIp", query = "SELECT l FROM LoginUser l WHERE l.ip = :ip"),
    @NamedQuery(name = "LoginUser.findByRole", query = "SELECT l FROM LoginUser l WHERE l.role = :role")})
public class LoginUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "uname")
    private String uname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "upass")
    private String upass;
    @Size(max = 2147483647)
    @Column(name = "ip")
    private String ip;
    @Basic(optional = false)
    @NotNull
    @Column(name = "role")
    private short role;

    public LoginUser() {
    }

    public LoginUser(Integer id) {
        this.id = id;
    }

    public LoginUser(Integer id, String uname, String upass, short role) {
        this.id = id;
        this.uname = uname;
        this.upass = upass;
        this.role = role;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getUpass() {
        return upass;
    }

    public void setUpass(String upass) {
        this.upass = upass;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public short getRole() {
        return role;
    }

    public void setRole(short role) {
        this.role = role;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LoginUser)) {
            return false;
        }
        LoginUser other = (LoginUser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jp.co.irep.tech.juten.jpa.entity.LoginUser[ id=" + id + " ]";
    }
    
}
